package com.example.controller;

import com.example.email.MailDto;
import com.example.email.MailService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api
@RestController
@RequestMapping("/email")
public class EmailController {
    @Resource
    private MailService mailService;

    @PostMapping("/send")
    public void sendEmail(String author,String to,String text){
        //发送邮件
        MailDto mailDto = new MailDto();
        mailDto.setTo(to);
        mailDto.setSubject("收到您朋友【"+author+"】的信件");
        mailDto.setText(text);
        mailService.sendMail(mailDto);
    }

}
